
cc.Class({
    extends: cc.Component,

    properties: {
        nickName:{
            get(){
                let node=this.node.getChildByName('昵称').getChildByName('昵称文字');
                return !!node?node.getComponent(cc.Label).string:'';
            },
            set(value){
                let node=this.node.getChildByName('昵称').getChildByName('昵称文字');
                if(!!node) node.getComponent(cc.Label).string=value;
            }
        },
        levelName:{
            get(){
                let node=this.node.getChildByName('段位').getChildByName('段位文字');
                return !!node?node.getComponent(cc.Label).string:'';
            },
            set(value){
                let node=this.node.getChildByName('段位').getChildByName('段位文字');
                if(!!node) node.getComponent(cc.Label).string=value;
            }
        },
        _avatarUrl:'',
        avatarUrl:{
            get(){
                return this._avatarUrl;
            },
            set(value){
                this._avatarUrl=value;
                cc.assetManager.downloader.downloadDomImage(value,null, (err, img) => {
                    if(err){
                        cc.error('玩家头像错误='+err)
                        return
                    }
                    let texture = new cc.Texture2D();
                    texture.initWithElement(img);
                    texture.handleLoadedTexture();
                    let node=this.node.getChildByName('头像');
                    //console.log(err);
                    node.spriteFrame = new cc.SpriteFrame(texture);;
                    //this.headNodeArr[0].getComponent(Sprite).spriteFrame = new cc.SpriteFrame(texture);
                })
            }
        },
    },

    start () {
        //this.avatarUrl='https://wx4.sinaimg.cn/mw690/0061Qq8Vly1gh7qrddniij30jg0jggnc.jpg';
        this.avatarUrl='https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKEOOD6zJGuIk700ISQphowicGgnQ241pjqibpibSGHCUFeQvaviafandHkl7DehAyNnXibiaRjhFuSVpicA/132?aa=aa.jpg';
    },

    // update (dt) {},
});
